import java.io.File;
import java.util.ArrayList;
import java.util.Random;


public class doString {
	public static void main(String[] args) {
		System.out.println(a("abc ac"));
	}
	
	private static String a(String oldstr){
	    int index = oldstr.lastIndexOf(" "); 
	    while (index >= 0) { 
	        System.out.print(oldstr.substring(index + 1) + " "); 
	        oldstr = oldstr.substring(0,index); 
	        index = oldstr.lastIndexOf(' '); 
	    } 
	    
	    return oldstr;
	}

	private static  String spiltWithBlank(String temp){
	        int lastIndex = 0;
	        for(int i = temp.length() - 1; i >= 0; i--){
	            if(String.valueOf(temp.charAt(i)) != " "){
	            	lastIndex = i - 1;
	            	break;
	            }
	        }
		
	    String[] s = temp.split(" ");
	    StringBuffer buffer = new StringBuffer();
	    for(int i = 0; i < s.length; i++){
	        buffer.append(reverseString(s[i]));
	        if(i != s.length - 1){
	            buffer.append(" ");
	        }
	    }
	    
	    for(int i = 0; i <= temp.length() - lastIndex; i++){
	        buffer.append(" ");
	    }
	    
	    return buffer.toString();
	}
		
	private static String reverseString(String temp){
	    StringBuffer s = new StringBuffer(temp);
	    return s.reverse().toString();
	}

	private static String reverseString2(String temp){
	    StringBuffer s = new StringBuffer();
	    for(int i = temp.length() - 1; i >= 0; i--){
	        char chr = temp.charAt(i);
	        s.append(chr);
	    }
	    
	    return s.toString();
	}
}